package com.f21.f21assessoria.validator;

import java.util.ResourceBundle;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

import org.springframework.validation.annotation.Validated;

import com.f21.f21assessoria.util.UtilMessage;

;
@FacesValidator(value="validatorCPF")
public class ValidatorCpf implements Validator {


	public void validate(FacesContext context, UIComponent component,
			Object value) throws ValidatorException {

		String cpf = value.toString();
		cpf = cpf.replace(".", "");
		cpf = cpf.replace("-", "");
		
		
		if (cpf.length() == 11)
			return;
		else
			throw new ValidatorException(UtilMessage.getErroMessageBundle("erro.validator.cpf"));
		
	}

}
